Throttle playback progress publishers to reduce UI lag#1510
Open
matalvernaz wants to merge 3 commits into
Open
Throttle playback progress publishers to reduce UI lag#1510matalvernaz wants to merge 3 commits into
matalvernaz wants to merge 3 commits into
Conversation
The .bookPlaying and .listeningProgressChanged notifications fire every second from the AVPlayer periodic time observer, causing recalculateProgress() to update multiple @published properties on every tick. Similarly, currentProgressPublisher and immediateProgressUpdatePublisher in ItemProgressView trigger per-second redraws for every visible library row. On lower-powered devices (e.g. iPhone SE 2), this causes noticeable UI lag during playback. This adds 500ms throttling on the player progress publishers (keeping slider updates smooth) and 1s throttling on the library progress views (matching the existing folderProgressUpdated throttle). Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
PlayerViewModel and ItemProgressView were both using literal throttle windows (500ms / 1s) in multiple subscriber pipelines. Promoted each to a documented private static constant on the owning type so the cadence is discoverable and the rationale (audio-tick suppression vs SwiftUI redraw cost) lives next to the value.
Contributor
Author
|
Caught up to current develop. Folded in a follow-up commit that pulls the throttle windows out into named constants with short docstrings explaining why each duration was chosen — the same literal |
bd6faac to
24a926a
Compare
Collaborator
|
I have to double check this, I have an iPhone SE 2 lent to someone, I just have to track it down, I'll put this on hold in the meantime |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #1509
.bookPlayingand.listeningProgressChangedsubscribers inPlayerViewModel(keeps slider updates smooth while halving redraws)currentProgressPublisherandimmediateProgressUpdatePublisherinItemProgressView(matches the existingfolderProgressUpdatedthrottle)Context
The AVPlayer periodic time observer fires every 1 second. Without throttling, each tick triggers
recalculateProgress()(updating ~6@Publishedproperties) and redraws every visible library row's progress ring. On lower-powered devices like the iPhone SE 2, this causes noticeable lag during playback.Test plan
🤖 Generated with Claude Code